home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/python
-
- # plaintoo, an app to grab the hashes with bkhive and samdump
- # written by Michael Zanetta grimmlin@pentoo.ch
- # Don't go further, it's ugly. Trust me, but, to quote pale_horse :
- # "Works is what matters, cute is for anals"
-
- import sys
- import pygtk
- pygtk.require('2.0')
- import gtk, os
-
- class RadioButtons:
- def callback(self, widget, data=None):
- print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
-
- def close_application(self, widget, event, data=None):
- # Do some cleanup
- if os.path.ismount('/mnt/plaintoo'):
- os.system('umount /mnt/plaintoo')
- if not os.path.ismount('/mnt/plaintoo'):
- os.system("rm -rf /mnt/plaintoo")
- if os.path.isdir("/tmp/plaintoo"):
- os.system("rm -rf /tmp/plaintoo")
- gtk.main_quit()
- return False
-
- def list_partitions(self):
- list_partitions=""" #!/bin/sh
- PARTS=`cat /proc/partitions | grep [0-9]$ | sed -e 's/.* //g'`
- PARTSX=`cat /proc/partitions | grep [a-z]$ | sed -e 's/.* //g' -e '/name/d'`
- for x in $PARTSX
- do
- # echo $PARTS
- # echo $PARTSX
- TEMP=`fdisk -l /dev/$x | grep Ext | sed -e 's/ .*//g' -e 's/.*\///g'`
- [ ! -z "${TEMP}" ] && PARTS=`echo $PARTS | sed -e 's:'$TEMP'::g'`
- done
- [ -e /var/tmp/part_found ] && rm /var/tmp/part_found
- #echo "next"
- for x in $PARTS
- do
- VAR=`disktype /dev/$x | egrep -m 1 -e "(NTFS|FAT)" | grep -v Ext`
- if [ ! "${VAR}" == "" ]; then
- echo ${x} >> /var/tmp/part_found
- fi
- done
- cat /var/tmp/part_found
- """
- wrapper = open("/var/tmp/spawn.sh", "w")
- wrapper.write(list_partitions)
- wrapper.close()
- cmd = "chmod a+x /var/tmp/spawn.sh && /var/tmp/spawn.sh"
-
- list = os.popen(cmd)
- data = ""
- data = os.read(list.fileno(),16384)
- data.splitlines()
- return data
-
- def list_dirs(self):
- os.remove("/var/tmp/spawn.sh")
- list_dir=""" #!/bin/sh
- find /mnt/plaintoo/ -type d -maxdepth 1 | sed -e 's/.*\///g'
- """
-
- wrapper = open("/var/tmp/spawn.sh", "w")
- wrapper.write(list_dir)
- wrapper.close()
- cmd = "chmod a+x /var/tmp/spawn.sh && /var/tmp/spawn.sh"
-
- list = os.popen(cmd)
- data = ""
- data = os.read(list.fileno(),16384)
- data.splitlines()
- return data
-
- def spawn(self, cmd, return_output=False):
- wrapper = open("/var/tmp/spawn.sh", "w")
- wrapper.write("#!/bin/bash -l\n" + cmd + "\nexit $?\n")
- wrapper.close()
- if self._debug:
- print cmd
- cmd = "chmod a+x /var/tmp/spawn.sh && /var/tmp/spawn.sh"
- ro_pipe = os.popen(cmd)
- data = os.read(ro_pipe.fileno(),16384)
- ret = ro_pipe.close() or 0
-
- if return_output:
- return ret, data
- else:
- return ret
-
- def set_windir(self, widget, dir):
- self.windir = dir
- if self._debug:
- print "Selected dir :" +dir
-
-
- def test(self, part):
- self.box2.destroy()
- self.window.resize_children()
- self.partitions_combo = gtk.combo_box_new_text()
- found_dirs = ""
- found_dirs = self.list_dirs().splitlines()
- print found_dirs
- for dir in found_dirs:
- self.partitions_combo.append_text(dir)
- if self._debug:
- self.partitions_combo.connect("changed", self.get_active_text)
- self.partitions_combo.set_active(0)
-
- def check_dir(self, part):
- self.box2.destroy()
- if self._debug:
- print part
- if not os.path.isdir('/mnt/plaintoo/'):
- os.system('mkdir /mnt/plaintoo/')
- if not os.path.ismount('/mnt/plaintoo'):
- os.system('mount /dev/' + part + ' /mnt/plaintoo')
- if not os.path.isdir('/mnt/plaintoo/' + self.windir):
- if self._debug:
- print self.windir + " does not exist"
- # Delete and recreate the combobox listing dirs
- content_str = """
-
- The directory """ + self.windir + """ cannot be found.
- Please select amongst the following.
- """
- content_label = gtk.Label(content_str)
-
- self.box2.destroy()
- self.box2 = gtk.VBox(False, 10)
- self.box2.pack_start(content_label, expand=False, fill=False, padding=0)
- hbox = gtk.HBox(False, 10)
- self.box2.pack_start(hbox, expand=False, fill=False, padding=0)
- self.window.resize_children()
- tmplabel = gtk.Label("Select dir :")
- tmplabel.set_alignment(0.0, 0.5)
- tmplabel.set_size_request(160, -1)
- hbox.pack_start(tmplabel, expand=False, fill=False, padding=0)
- self.partitions_combo = gtk.combo_box_new_text()
- hbox.pack_start(self.partitions_combo, expand=False, fill=False, padding=0)
- found_dirs = ""
- found_dirs = self.list_dirs().splitlines()
- print found_dirs
- for dir in found_dirs:
- self.partitions_combo.append_text(dir)
-
- self.partitions_combo.connect("changed", self.set_new_windir)
- self.partitions_combo.set_active(0)
- self.partitions_combo.show()
- self.box2.show_all()
- #self.box2.show()
- self.box1.pack_start(self.box2, expand=False, fill=False, padding=0)
- self.box1.show_all()
- #self.box1.show()
-
-
- #TODO: Gerer le cas du unmount,
- #os.system('umount /mnt/plaintoo')
- else:
- pathtoconf= "/mnt/plaintoo/" + self.windir + '/system32/config'
- if self._debug:
- print "OK"
- if not os.path.isdir(pathtoconf):
- return 1
- else:
- exitstatus = self.spawn("bkhive " + pathtoconf + '/system /tmp/plaintoo/key')
- if exitstatus != 0:
- return 1
- if not os.path.isfile("/tmp/plaintoo/key"):
- return 1
- existatus, passlist = self.spawn("samdump2 " + pathtoconf + '/SAM /tmp/plaintoo/key 2>/dev/null', return_output=True)
- if len(passlist) < 10:
- passlist = "Could not grab any hashes..."
- if self._debug:
- print passlist
- self.button_next.destroy()
- content_str = """
-
- Here are the hashes found.
- """
- content_label = gtk.Label(content_str)
-
- self.box2.destroy()
- self.box2 = gtk.VBox(False, 40)
- self.box2.pack_start(content_label, expand=False, fill=False, padding=0)
- self.logtextbuff = gtk.TextBuffer()
- self.logtextbuff.set_text(passlist)
- self.logtextview = gtk.TextView(self.logtextbuff)
- self.logtextview.set_editable(False)
- self.logtextviewscroll = gtk.ScrolledWindow()
- self.logtextviewscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- self.logtextviewscroll.add(self.logtextview)
- self.box2.pack_start(self.logtextviewscroll, expand=True, fill=True)
- # Add the button for FF -> plain-text.info
- buttonbox = gtk.HBox(False, 10)
- button_pt = gtk.Button()
- buttonlabel = gtk.Label("Crack online")
- buttonlabel.set_use_underline(True)
- buttonimg = gtk.Image()
- buttonimg.set_from_file('./img/pt.png')
- buttonbox.pack_start(buttonimg)
- buttonbox.pack_start(buttonlabel)
- button_pt.add(buttonbox)
- button_pt.connect_object("clicked", self.open_ff, None)
- fill = gtk.HBox(False,10)
-
- container = gtk.HBox(False, 10)
- container.pack_start(fill, expand=True, fill=True, padding=0)
- container.pack_start(button_pt, expand=False, fill=False, padding=0)
- fill = gtk.HBox(False,10)
- container.pack_start(fill, expand=True, fill=True, padding=0)
- container.show_all()
-
- self.box2.pack_start(container, expand=False, fill=False, padding=0)
- self.box2.show_all()
- self.box1.pack_start(self.box2, expand=False, fill=False, padding=0)
- self.box1.show_all()
-
- def open_ff(self, toto):
- os.system("firefox http://www.plain-text.info/")
-
- def get_active_text(self, combobox):
- data = ""
- model = combobox.get_model()
- index = combobox.get_active()
- data = model[index][0]
- if self._debug:
- print "Selected disk: " + data
- self.check_dir(data)
- return data
-
- def set_new_windir(self, combobox):
- data = ""
- model = combobox.get_model()
- index = combobox.get_active()
- data = model[index][0]
- if self._debug:
- print "Selected new dir: " + data
- self.windir = data
-
-
- def __init__(self):
- if not os.path.isdir("/tmp/plaintoo"):
- os.system("mkdir /tmp/plaintoo")
- self.windir = "WINNT"
- self._debug=False
-
- for arg in sys.argv:
- if arg == "-d" or arg == "--debug":
- self._debug = True
-
- # Construct window
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- self.window.connect("delete_event", self.close_application)
- self.window.set_title("Grab the hash with plaintoo/plain-text.info")
- self.window.set_border_width(0)
- self.window.set_default_size(400,400)
- self.window.set_geometry_hints(None, min_width=400, min_height=400, max_width=400, max_height=400)
-
-
- # Banner image
- animpixbuf = gtk.gdk.PixbufAnimation('./img/plaintoo.gif')
- image = gtk.Image()
- image.set_from_animation(animpixbuf)
- image.show()
-
- self.box1 = gtk.VBox(False, 0)
- self.window.add(self.box1)
- self.box1.pack_start(image, expand=False, fill=False, padding=0)
-
- content_str = """Please select wich windows version you want to grab
- the hashes from.
- """
- content_label = gtk.Label(content_str)
-
-
- self.box2 = gtk.VBox(False, 10)
- self.box2.set_border_width(10)
- self.box2.pack_start(content_label, expand=False, fill=False, padding=10)
- content_label.show()
- self.box1.pack_start(self.box2, expand=False, fill=False, padding=10)
- self.box1.show()
- self.box2.show()
-
- button = gtk.RadioButton(None, "Windows XP/2003")
- button.set_name("Windows XP or Windows 2003")
- button.connect("toggled", self.set_windir, "WINDOWS")
- self.box2.pack_start(button, expand=False, fill=False, padding=0)
- button.show()
-
- button = gtk.RadioButton(button, "Windows 2000/NT 4")
- button.connect("toggled", self.set_windir, "WINNT")
- button.set_active(True)
- self.box2.pack_start(button, expand=False, fill=False, padding=0)
- button.show()
-
-
- hbox = gtk.HBox(False, 0)
- tmplabel = gtk.Label("Select Drive:")
- tmplabel.set_alignment(0.0, 0.5)
- tmplabel.set_size_request(160, -1)
- hbox.pack_start(tmplabel, expand=False, fill=False, padding=0)
- self.partitions_combo = gtk.combo_box_new_text()
- hbox.pack_start(self.partitions_combo, expand=False, fill=False, padding=0)
- found_parts = ""
- found_parts = self.list_partitions().splitlines()
- for device in found_parts:
- self.partitions_combo.append_text(device)
- #if self._debug:
- #self.partitions_combo.connect("changed", self.get_active_text)
- self.partitions_combo.set_active(0)
- #self.partitions_combo.set_text_column(0)
-
- hbox.show_all()
- hbox.show()
- self.box2.pack_start(hbox, expand=False, fill=False, padding=15)
-
- self.bottom_box = gtk.HBox(False, 10)
- self.bottom_box.set_border_width(10)
- self.box1.pack_end(self.bottom_box, expand=False, fill=False, padding=0)
- separator = gtk.HSeparator()
- self.bottom_box.pack_start(separator, expand=False, fill=False, padding=0)
- separator.show()
- self.bottom_box.show_all()
-
- buttonbox = gtk.HBox(False, 10)
- button_close = gtk.Button()
- buttonlabel = gtk.Label("Quit")
- buttonlabel.set_use_underline(True)
- buttonimg = gtk.Image()
- buttonimg.set_from_file('./img/stock_exit.png')
- buttonbox.pack_start(buttonimg)
- buttonbox.pack_start(buttonlabel)
- button_close.add(buttonbox)
- button_close.connect_object("clicked", self.close_application, self.window,
- None)
-
- buttonbox = gtk.HBox(False, 10)
- self.button_next = gtk.Button()
- buttonlabel = gtk.Label("Next")
- buttonlabel.set_use_underline(True)
- buttonimg = gtk.Image()
- buttonimg.set_from_file('./img/stock_right.png')
- buttonbox.pack_start(buttonimg)
- buttonbox.pack_start(buttonlabel)
- self.button_next.add(buttonbox)
- self.button_next.connect_object("clicked", self.get_active_text, self.partitions_combo)
- self.bottom_box.pack_start(button_close, expand=False, fill=False, padding=5)
- self.bottom_box.pack_end(self.button_next, expand=False, fill=False, padding=5)
- button.set_flags(gtk.CAN_DEFAULT)
- button.grab_default()
- self.bottom_box.show_all()
- self.window.show()
-
-
- def main():
- gtk.main()
- return 0
-
- if __name__ == "__main__":
- RadioButtons()
- main()
-